home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / docs-source / source.hsc < prev    next >
Encoding:
Text File  |  1997-10-24  |  10.3 KB  |  274 lines

  1. <WEBPAGE chapter="hsc - " title="The Source Code"
  2.     PREV="questions.html"
  3.     NEXT="ports.html"
  4.     QTEXT=("I've been swimming in the dirty water<BR>"
  5.           +"I've been swimming where the fish won't go")
  6.     QAUTHOR='The Jesus & Mary Chain, "Dirty Water"'>
  7.  
  8. Not for all systems there already compiled versions of this package
  9. available. If you can not find binaries anywhere, it seems you will
  10. have to go on. Otherwise, you can skip this chapter, as it does not
  11. contain anything you would want to know.
  12.  
  13. <H2>Availability</H2>
  14.  
  15. <P>The source archive should be available from the same locations
  16. where you are supposed to get <A HREF="updates.html">updates</A>
  17. from. Look out for an archive called <FILE>hsc-source.lha</FILE>.
  18.  
  19. <H2>Portability</H2>
  20.  
  21. <P><hsc CAP> was written in naked & masochistic ANSI-C. Even worse, it
  22. only uses functions of the standard library and does not require any
  23. Amiga- or Un*x-specific include files like <TG>dir.h</TG>,
  24. <TG>String.h</TG> or functions like <CODE>ReadArgs()</CODE>,
  25. <CODE>stricmp()</CODE> etc.</P>
  26.  
  27. <P>This should ensure a maximum of portability. However, the handling
  28. of filenames is a system-dependent thing, which has to be adapted for
  29. every OS. See also the section about <A HREF="ports.html">Existing
  30. Ports</A>.</P>
  31.  
  32. <H2>Compiling Under RiscOS</H2>
  33.  
  34. For RiscOS, there is a special <makefile> and <FILE>ReadMe</FILE>
  35. you can find in the <FILE>riscos</FILE> directory.
  36.  
  37. <H2>Compiling</H2>
  38.  
  39. <P>Basically, compilation works like this: You will need a command
  40. line based C-compiler. The compiler <EM>must</EM> support ANSI-C.
  41. There is a <makefile> which contains settings for all supported
  42. systems. You will have to comment in yours. After that you can launch
  43. the <make> tool and should hopefully end up with the binaries.</P>
  44.  
  45. Ok, now all those steps in detail:
  46.  
  47. <OL>
  48.  
  49. <LI>If you've compiled older versions of <hsc> before, remove all
  50. files of the old sources before you continue. Do not extract a newer
  51. source archive into a directory containing older ones.
  52.  
  53. <LI>Change your current directory to the <FILE>source</FILE> directory
  54.  
  55. <LI>Now load the <makefile> into your editor. Make sure your editor is
  56. able to preserve TABs. If it does not, <make> might have some trouble
  57. afterwards.
  58.  
  59. <LI> Figure out which system and compiler you have, and remove the
  60. <hash> from the corresponding lines.
  61.  
  62. <LI>Go back to command line and type <KBD>make</KBD>. Lots of strange
  63. message should show up indicating that a compiler is started and that
  64. there are many options passed to it.
  65.  
  66. <LI>If there is an error - bad luck. If you do not know what to do now
  67. (for example starting to fool around with the <makefile>, fix and
  68. report the bug) - worse luck. Go to the cinema or do something else,
  69. but forget about this software.
  70. </OL>
  71.  
  72. <H2>Compiler Warnings</H2>
  73.  
  74. <P>If the compilation was successful, but some compiler warnings
  75. showed up, it depends if you should take it serious or not. There are
  76. certain parts of the code which declare functions and symbols, but not
  77. actually use them (they use them in debug-mode, but I did not want to
  78. clutter the source with too many <CODE>#ifdef</CODE>s). During linking
  79. stage this code should be kicked out anyway. You can safely ignore
  80. this.</P>
  81.  
  82. <P>Other warnings indicate a compiler bug. Contact your compiler
  83. vendor.</P>
  84.  
  85. <P>Ok, maybe not. If you think it could be a nasty one, do a bug
  86. report on <hsc>.</P>
  87.  
  88. <H2>The Binaries</H2>
  89.  
  90. If all went well, you now should have created three files:
  91.  
  92. <PRE>
  93. hsc/hsc
  94. hsctools/hscdepp
  95. hsctools/hscpitt
  96. </PRE>
  97.  
  98. <P>These are the executables. Congratulations. Mark the current day in
  99. your calendar with a red circle. After that, follow the <A
  100. HREF="install.html">installation instructions</A>. (In short: put the
  101. binaries somewhere in your search-path, and setup hsc.prefs in the
  102. appropriate place.)</P>
  103.  
  104. <H2>Cleaning Up</H2>
  105.  
  106. To remove the object files, use
  107.  
  108. <PRE>make clean</PRE>
  109.  
  110. To also remove binaries, temporary files, core dumps and other trash, use
  111.  
  112. <PRE>make sterile</PRE>
  113.  
  114. In ideal case, the <FILE>source</FILE> directory should then be in
  115. exactly the same state as it was before you started with the
  116. compilation.
  117.  
  118. <H2>Basic Test Run</H2>
  119.  
  120. Now it is probably a good time to check if <hsc> basically runs without
  121. crashing. Later in this chapter you will read how to do a more exhaustive
  122. test run, but for now simply type this into your command line:
  123.  
  124. <PRE>hsc/hsc test/simple.hsc to test/simple.html status=full prefsfile=../hsc.prefs</PRE>
  125.  
  126. If there now is a file <FILE>test/simple.html</FILE> which looks
  127. pretty much the same as <FILE>test/simple.hsc</FILE>, and the output
  128. on the display looks something like
  129.  
  130. <PRE>hsc - html sucks completely, v0.XXX (dd-mmm-yy)
  131. (C) T.Aglassinger/Tommy-Saftwörx. Freeware, type `hsc LICENSE' for details.
  132. ../hsc.prefs: preferences read
  133. test/simple.hsc (9)</PRE>
  134.  
  135. <hsc> passed this test. In this case, you can continue reading at the
  136. next heading.
  137.  
  138. <P>But if you now see something like</P>
  139.  
  140. <PRE>*** atexit() failed: Unknown error code</PRE>
  141.  
  142. <P>on your display, you are most likely running under <Nextstep>.
  143. There it seems to be a known bug of the ANSI-C function
  144. <CODE>atexit()</CODE> to return with in error code even in case of
  145. success. However, nobody ever cared about fixing this, and even in
  146. OpenStep 4.2 this bug still seems to be there.</P>
  147.  
  148. <P>As I do not care about faulty implementations of basic ANSI-C
  149. functions, you will have to change the source code to make it ignore
  150. the result of <CODE>atexit()</CODE>. Load
  151. <file>source/hsc/hsc.c</file> into your editor and change the line</P>
  152.  
  153. <PRE>if (atexit(func))</PRE>
  154.  
  155. into something like
  156.  
  157. <PRE>if (atexit(func) && 0)</PRE>
  158.  
  159. <P>to still call this function and add the additional exit-function,
  160. but ignore any errors returned by it. At least this is the work-around
  161. suggested to me. And no, there will not be a <CODE>#ifdef
  162. NEXTSTEP</CODE> for this stupid bug in the runtime library.</P>
  163.  
  164. <H2>About Makefile.agi</H2>
  165.  
  166. <P>If you sneaked around about in the <FILE>source</FILE> directory,
  167. you maybe also stumbled across a filed called
  168. <FILE>Makefile.agi</FILE>.</P>
  169.  
  170. <P>Actually I don't use the normal <Makefile> described in the early
  171. chapters above for developing. The reason should be obvious, if you
  172. watched your compiler before. It only has been invoked a few times,
  173. but the there are several small source files.</P>
  174.  
  175. <P>This is simply because every sub-part of this package has a
  176. file which includes all corresponding small files into a single
  177. big one. The compiler will have to work quite a while on this,
  178. and it will take much more resources - especially memory.</P>
  179.  
  180. <P>But the optimizer will be more efficient (shorter and faster code),
  181. and, most important, there are no problems with any library managers,
  182. complex and hardly portable rules in the <Makefile> and so on.</P>
  183.  
  184. <P>If you just want to compile it once, this is fine for you. However,
  185. if one still develops on this package, and has to change and compile
  186. sources very often, this is not acceptable: A small change will cause
  187. the compiler to recompile large parts, lasting a very long time.</P>
  188.  
  189. <P>Therefor <Makefile.agi> uses a library manager to avoid this. It
  190. is easy for me to make sure that this specific <Makefile> runs on my
  191. machine, with the <make> tool installed on my machine. But it might not
  192. necessarily work with yours.</P>
  193.  
  194. <P>But the standard <makefile> (probably) did. So that's why.</P>
  195.  
  196. <P>However, there might be one reason why you still want to partially
  197. use it:</P>
  198.  
  199. <H2>Performing a Test Run</H2>
  200.  
  201. <P>To test if hsc works as expected, some test data are included in
  202. <FILE>source/test/</FILE>. Please note that this material might not be
  203. up to date for pre-releases you have downloaded from the
  204. support-w3-page. Some of the tests might file in such releases.</P>
  205.  
  206. <P>The <CODE>test</CODE> rule is only declared in <makefile.agi>. This
  207. <makefile> uses some features not supported by all <make> tools. It
  208. has been designed to work with <EXEC>GNUmake</EXEC>, which is freely
  209. available together with it's source code (see <ln_related>).</P>
  210.  
  211. <P>To initiate the test sequence, simple type</P>
  212.  
  213. <PRE>make -f Makefile.agi test</PRE>
  214.  
  215. <P>from the same directory you have started the compilation before.</P>
  216.  
  217. <P>Technically speaking, the test run does the following: it will
  218. invoke <hsc> several times: some <FILE>.hsc</FILE> files will be used
  219. to create some <FILE>.html</FILE> files. These are compared with
  220. <FILE>.expected</FILE> files, which have been created before and
  221. contain the expected output.</P>
  222.  
  223. <P>For this comparison, <EXEC>diff --brief</EXEC> will used. Make sure
  224. that such a command is available before starting the test process
  225. (again, see <ln_related> if you do not have it).</P>
  226.  
  227. <P>Additionally, <hsc> will redirect messages to <FILE>.msg</FILE>
  228. files. These will be compared with <FILE>.mex</FILE>
  229. files(<qq>messages expected</qq>) the same way as described above.</P>
  230.  
  231. <P>If all works fine, `diff' should not produce any output.</P>
  232.  
  233. <P>But you should be aware that the test run also includes some faulty
  234. input data to test if hsc is able to cope with certain error
  235. situations. These will result in an output like</P>
  236.  
  237. <PRE>
  238. testing test/unknattr.hsc (messages only)..
  239. hsc/hsc failed returncode 10
  240. make: [test/unknattr.msg] Error 10 (ignored)
  241. </PRE>
  242.  
  243. <P>and should not confuse you. Only an error reported by
  244. <EXEC>diff</EXEC> counts as a failed test run.</P>
  245.  
  246. <H2><A NAME="debug">Debug Mode</A></H2>
  247.  
  248. <P>These paragraphs are most likely only interesting for freaky
  249. people. Normally you do not want to compile <hsc> in debug mode.
  250. Therefor I am not going to explain many details about it, but it
  251. should be sufficient for those it is directed to.</P>
  252.  
  253. <P>In debug mode, <hsc> performs some additional plausibility checks.
  254. Most remarkable, it will check for unreleased resources and trashed
  255. memory. It will also output some statistic at the end of every
  256. run.</P>
  257.  
  258. <P>To compile it for this mode, you have to define two symbols called
  259. <CODE>DEBUG</CODE> and <CODE>DEBUG_UGLY</CODE>. After that, you can
  260. use the CLI option <KBD>-DEBUG</KBD> to enable this additional
  261. output.</P>
  262.  
  263. <P>It does not make sense to run <hsc> in debug mode all the time, as
  264. it is (even more) horrible slow in it. You should only use this if you
  265. want to trace internal error messages, some completely unreasonable
  266. behavior or crashes.</P>
  267.  
  268. <P>If you still can not get enough of debugging information, you can
  269. take a look at the source files <FILE>hsclib/ldebug.h</FILE> and
  270. <FILE>ugly/udebug.h</FILE>, where you can set some additional
  271. flags to <CODE>1</CODE>.</P>
  272.  
  273. </WEBPAGE>
  274.